<%@ page contentType='text/html; charset=iso-8859-1' language="java"%>
<%@ page pageEncoding="UTF-8"%>
<%@ include file="../WEB-INF/jspf/acesso.jspf" %>
<%@ include file="../WEB-INF/jspf/setMeta.jspf" %>
<%@ include file="../WEB-INF/jspf/varGlobal.jspf" %>


<sql:query var='rsetUsuario' dataSource='${con}'>
    
    SELECT Usuario.usuario, Usuario.senha, Usuario.nome, Usuario.equipe FROM Usuario 
    WHERE (Usuario.usuario = '${param.usuario}' 
    AND Usuario.senha = '${param.senha}')
    
</sql:query> 


    <html>
    <head></head>
    <body onload="javascript:monta()">
    <c:choose>
        <c:when test="${(param.usuario == rsetUsuario.rowsByIndex[0][0]) && (param.senha == rsetUsuario.rowsByIndex[0][1])}">
            <% 
                // String equipe = "<c:out value="${rsetUsuario.rowsByIndex[0][1]}"/>";
                
                Cookie inscricao = new Cookie ("inscricao","1");
                response.addCookie(inscricao);

                session.putValue("usuarioLogado", request.getParameter("usuario"));
                session.putValue("usuarioEquipe", "UGSAC" );
      
            %>
            
            <form name="form1" method="post" action="../controller/registrarLogLogin.jsp">
            
          <input type="hidden" name="idLogSGCA" value="" />
          <input type="hidden" name="usuario" value="" />
          <input type="hidden" name="idSolicitacao" value="" />
          <input type="hidden" name="equipe" value="" />
          <input type="hidden" name="cliente" value="" />
          <input type="hidden" name="dataLog" value="" />
          <input type="hidden" name="horaLog" value="" />
          <input type="hidden" name="acao" value="" />
          <input type="hidden" name="nomeComputador" value="" />
          <input type="hidden" name="ipComputador" value="" />
          <input type="hidden" name="proxPagina" value="../interface/visualizarSolicitacoesEmAtendimento.jsp" />
          <input type="hidden" name="mensagem" value="" />
          
    <script language="javascript" type="text/javascript">
      
      function monta(){ 
      
     
              document.form1.usuario.value = "${rsetUsuario.rowsByIndex[0][2]}";
              document.form1.idSolicitacao.value = "";
              document.form1.equipe.value = "${rsetUsuario.rowsByIndex[0][3]}";
              document.form1.cliente.value = "";
              document.form1.dataLog.value = "<c:out value=""/>";
              document.form1.horaLog.value = "<c:out value=""/>";
              document.form1.acao.value = "${rsetUsuario.rowsByIndex[0][2]} efetuou login no sistema.";
              document.form1.nomeComputador.value = "<c:out value=""/>";
              document.form1.ipComputador.value = "<c:out value=""/>";
              document.form1.submit();
              }
      
      </script>
        
    </c:when>
    <c:otherwise>
        <script language="javascript">
            alert("Usuário ou Senha incorreta" );
            history.go(-1);
        </script>
    </c:otherwise>
  </c:choose>

    </body>
    </html>
    
        
        
        
 


